package com.liachen.stock.ext.impl;

import com.alibaba.fastjson.JSONObject;
import com.liachen.common.constant.Constant;
import com.liachen.stock.ext.WxService;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

import java.io.IOException;

/**
 * 微信serviceImpl
 *
 * @author chen.liang
 * @date 2020/6/12 9:20
 * @since V1.0
 */
public class WxServiceImpl implements WxService {
    @Override
    public JSONObject getContent() {
        try {
            Document doc = Jsoup.connect("https://mp.weixin.qq.com/mp/profile_ext?action=home&__biz=MzIzMjQ3NDA0Mg==&scene=123&uin=MTI0MDMyNzYwMg%3D%3D&key=f7df9c827b11864cf892e9dd92d8b0408b681e28cc109bcec2d66bb1e7fcb478f80cb8c5c60aaf7a108bbf627b587a1093075a4c2b1a0452a54bafe8eecc09dd829c5084e31237000e736abb0ca5acc6&devicetype=Windows+10+x64&version=6209007b&lang=zh_CN&a8scene=1&pass_ticket=zscAHpdByeqD30CuXYuVnyHH32wYqZeBwGtWSjG6N%2BSnGsbYBanquCb%2FpWp1NgsR").userAgent(Constant.MM_USER_AGENT).get();
            System.out.println(doc.text());
            Elements elements = doc.select("#WXAPPMSG1000001057 > div > h4");
            for (Element element : elements) {
                System.out.println(JSONObject.toJSONString(element));
                System.out.println(element.text());
                System.out.println(element.attr("hrefs"));
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
        return null;
    }

    public static void main(String[] args) {
        WxServiceImpl test = new WxServiceImpl();
        test.getContent();
    }
}
